<?php
session_start();
include_once 'includes/utilities.php';
$link = OpenDB();
require_once 'class.phpmailer.php';
$protocolo = $_SESSION["protocolo"];
$msg = ($_POST["msg"] != "") ? $_POST["msg"] : "Se adjunta informe";
$mailMedico = $_POST["mailMedico"];
$mailPaciente = $_POST["mailPaciente"];
$subject = GetValue("asunto email");
$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->SetFrom('araufernando@hotmail.com', 'Patologia');
$mail->CharSet = "UTF-8";
$mail->AddReplyTo('araufernando@hotmail.com',$name='');
if ($mailMedico != "")
    $mail->AddAddress($mailMedico ,$name='');
if ($mailPaciente != "")
    $mail->AddAddress($mailPaciente ,$name='');
$mail->Subject = $subject;
$mail->AltBody = "Mensaje en formato HTLM"; // optional, comment out and test
$mail->MsgHTML($msg);
$mail->AddAttachment('informes/'.$protocolo.'.pdf', $name = "Informe.pdf", $encoding = "base64", $type = "application/octet-stream");
$mail->Send();
CloseDB($link);
?>
